package com.soul.soulcommon.detail;

import com.soul.soulcommon.dto.Jwt;
import com.soul.souldao.domain.Doctor;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class DoctorDetail implements UserDetails {
    private Jwt jwt;
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        List<GrantedAuthority> authorities = new ArrayList<>();
        if (jwt.getRoleName() != null) {
            authorities.add(new SimpleGrantedAuthority(jwt.getRoleName()));
        }
        return authorities;
    }

    @Override
    public String getPassword() {
        return jwt.getPassword();
    }

    @Override
    public String getUsername() {
        return jwt.getUserName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
